package cn.tedu.weibonew.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMVCConfiguration implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // /**匹配任意请求路径
        registry.addMapping("/**")
                .allowedHeaders("*")   //允许任意请求头访问
                .allowedMethods("*")   //允许任意请求方式(get/post/put/delete)
                .allowedOriginPatterns("*")//允许任意请求域
                .allowCredentials(true)  //允许携带session相关信息
                .maxAge(3600); //设置1小时内同一请求不再检测
    }
}
